<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>PagerDuty action | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'actions-pagerduty.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/actions-pagerduty.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/actions-pagerduty.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/actions-pagerduty.html" rel="nofollow" target="_blank">../en/actions-pagerduty.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="xpack-alerting.html">Alerting on cluster and index events</a></span>
»
<span class="breadcrumb-link"><a href="actions.html">Actions</a></span>
»
<span class="breadcrumb-node">PagerDuty action</span>
</div>
<div class="navheader">
<span class="prev">
<a href="actions-slack.html">« Slack Action</a>
</span>
<span class="next">
<a href="actions-jira.html">Jira action »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="actions-pagerduty"></a>PagerDuty action<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/pagerduty.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>Use the PagerDuty action to create events in <a href="https://pagerduty.com/" class="ulink" target="_top">
PagerDuty</a>. To create PagerDuty events, you must <a class="xref" href="actions-pagerduty.html#configuring-pagerduty" title="Configuring PagerDuty accounts">configure at least one PagerDuty account</a> in <code class="literal">elasticsearch.yml</code>.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="configuring-pagerduty-actions"></a>Configuring PagerDuty actions<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/pagerduty.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You configure PagerDuty actions in the <code class="literal">actions</code> array. Action-specific attributes
are specified using the <code class="literal">pagerduty</code> keyword.</p>
<p>The following snippet shows a simple PagerDuty action definition:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">"actions" : {
  "notify-pagerduty" : {
    "transform" : { ... },
    "throttle_period" : "5m",
    "pagerduty" : {
      "description" : "Main system down, please check!" <a id="CO530-1"></a><i class="conum" data-value="1"></i>
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO530-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Description of the message</p>
</td>
</tr>
</table>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="adding-context-and-payloads-to-pagerduty-actions"></a>Adding meta information to a PagerDuty incident<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/pagerduty.asciidoc">edit</a>
</h3>
</div></div></div>
<p>To give the PagerDuty incident some more context, you can attach the
payload as well as an array of contexts to the action.</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">"actions" : {
  "notify-pagerduty" : {
    "throttle_period" : "5m",
    "pagerduty" : {
      "account" : "team1",
      "description" : "Main system down, please check! Happened at {{ctx.execution_time}}"
      "attach_payload" : true,
      "client" : "/foo/bar/{{ctx.watch_id}}",
      "client_url" : "http://www.example.org/",
      "contexts" : [
        {
          "type": "link",
          "href": "http://acme.pagerduty.com"
        },{
          "type": "link",
          "href": "http://acme.pagerduty.com",
          "text": "View the incident on {{ctx.payload.link}}"
        }
      ]
    }
  }
}</pre>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="pagerduty-action-attributes"></a>Pagerduty action attributes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/pagerduty.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="informaltable">
<table border="1" cellpadding="4px">
<colgroup>
<col class="col_1">
<col class="col_2">
<col class="col_3">
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="center" valign="top">Required</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">account</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>The account to use, falls back to the default one.
                            The account needs a <code class="literal">service_api_key</code> attribute.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="table">
<a id="pagerduty-event-trigger-incident-attributes"></a>
<p class="title"><strong>Table 91. Pagerduty event trigger incident attributes</strong></p>
<div class="table-contents">
<table border="1" cellpadding="4px" summary="Pagerduty event trigger incident attributes">
<colgroup>
<col class="col_1">
<col class="col_2">
<col class="col_3">
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="center" valign="top">Required</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">description</code></p></td>
<td align="center" valign="top"><p>yes</p></td>
<td align="left" valign="top"><p>A quick description for this event</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">event_type</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>The event type to sent. Must be one of <code class="literal">trigger</code>,
                                <code class="literal">resolve</code> or <code class="literal">acknowledge</code>. Defaults to <code class="literal">trigger</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">incident_key</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>The incident key on the pagerduty side, also used
                                for de-duplication and allows to resolve or acknowledge
                                incidents.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">client</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>Name of the client triggering the incident, i.e.
                                <code class="literal">Watcher Monitoring</code></p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">client_url</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>A client URL to visit to get more detailed information.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">attach_payload</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>If set to <code class="literal">true</code> the payload is attached as a detail
                                to the API call. Defaults to <code class="literal">false</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">contexts</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>An array of objects, that allow you to provide
                                additional links or images in order to provide more
                                context to the trigger.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">proxy.host</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>The proxy host to use (only in combination with <code class="literal">proxy.port</code>)</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">proxy.port</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>The proxy port to use (only in combination with <code class="literal">proxy.host</code>)</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<p>You can configure defaults for the above values for the whole service using the
<code class="literal">xpack.notification.pagerduty.event_defaults.*</code> properties as well as
per account using <code class="literal">xpack.notification.pagerduty.account.your_account_name.event_defaults.*</code></p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>All of those objects have templating support, so you can use data from the
      context and the payload as part of all the fields.</p>
</div>
</div>
<div class="table">
<a id="pagerduty-event-trigger-context-attributes"></a>
<p class="title"><strong>Table 92. Pagerduty event trigger context attributes</strong></p>
<div class="table-contents">
<table border="1" cellpadding="4px" summary="Pagerduty event trigger context attributes">
<colgroup>
<col class="col_1">
<col class="col_2">
<col class="col_3">
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="center" valign="top">Required</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">type</code></p></td>
<td align="center" valign="top"><p>yes</p></td>
<td align="left" valign="top"><p>One of <code class="literal">link</code> or <code class="literal">image</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">href</code></p></td>
<td align="center" valign="top"><p>yes/no</p></td>
<td align="left" valign="top"><p>A link to include more information. Must be there if the
                      type is <code class="literal">link</code>, optional if the type is <code class="literal">image</code></p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">src</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>A src attribute for the <code class="literal">image</code> type.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="configuring-pagerduty"></a>Configuring PagerDuty accounts<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/pagerduty.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You configure the accounts Watcher uses to communicate with PagerDuty in
the <code class="literal">xpack.notification.pagerduty</code> namespace in <code class="literal">elasticsearch.yml</code>.</p>
<p>To configure a PagerDuty account, you need the API integration key for
the PagerDuty service you want to send notifications to. To get the
key:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
Log in to <a href="http://pagerduty.com" class="ulink" target="_top">pagerduty.com</a> as an account administrator.
</li>
<li class="listitem">
<p>Go to <span class="strong strong"><strong>Configuration &gt; Services</strong></span> and select the PagerDuty service. The
service must use the API integration.</p>
<div class="imageblock">
<div class="content">
<img src="../static/images/pagerduty-services.jpg" alt="pagerduty services">
</div>
</div>
</li>
<li class="listitem">
<p>Click the <span class="strong strong"><strong>Integrations</strong></span> tab and copy the API integration key.</p>
<div class="imageblock">
<div class="content">
<img src="../static/images/pagerduty-integrations.jpg" alt="pagerduty integrations">
</div>
</div>
</li>
</ol>
</div>
<p>To configure a PagerDuty account in the keystore, you
must specify an account name and integration key, (see <a class="xref" href="secure-settings.html" title="Secure settings">Secure settings</a>):</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">bin/elasticsearch-keystore add xpack.notification.pagerduty.account.my_pagerduty_account.secure_service_api_key</pre>
</div>
<div class="warning admon">
<div class="icon"></div>
<div class="admon_content">
<h3>Deprecated in 7.0.0.</h3>
<p>Storing the service api key in the YAML file or via cluster update settings is still supported, but the keystore setting should be used.</p>
</div>
</div>
<p>You can also specify defaults for the
<a class="xref" href="actions-pagerduty.html#pagerduty-event-trigger-incident-attributes" title="Pagerduty event trigger incident attributes">PagerDuty event attributes</a>:
.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.pagerduty:
  account:
    my_pagerduty_account:
      event_defaults:
        description: "Watch notification"
        incident_key: "my_incident_key"
        client: "my_client"
        client_url: http://www.example.org
        event_type: trigger
        attach_payload: true</pre>
</div>
<p>If you configure multiple PagerDuty accounts, you either need to set a default
account or specify which account the event should be sent with in the
<a class="xref" href="actions-pagerduty.html" title="PagerDuty action"><code class="literal">pagerduty</code></a> action.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.pagerduty:
  default_account: team1
  account:
    team1:
      ...
    team2:
      ...</pre>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="actions-slack.html">« Slack Action</a>
</span>
<span class="next">
<a href="actions-jira.html">Jira action »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>